package com.firewolf.fr.s011_xml;

import java.io.File;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.util.HashMap;
import java.util.Map;

import freemarker.ext.dom.NodeModel;
import freemarker.template.Configuration;
import freemarker.template.Template;

/**
 * 空值处理
 * 
 * @author liuxing
 *
 */
public class XML {
	public static void main(String[] args) throws Exception {

		Configuration cfg = new Configuration(Configuration.VERSION_2_3_23);
		cfg.setDirectoryForTemplateLoading(new File("ftl"));
		Template tl = cfg.getTemplate("011_xml.ftl");
		Writer w = new OutputStreamWriter(System.out);// 把数据显示到控制台
		Map<String,Object> model = new HashMap<>();
		model.put("xml", NodeModel.parse(new File("11_xml/users.xml")));
		tl.process(model, w);
		w.flush();
	}
}
